package com.sikaryofficial.backend.controller.store;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sikaryofficial.backend.domain.dto.req.store.StoreCommentListReq;
import com.sikaryofficial.backend.domain.dto.req.store.StoreCommentReplySaveReq;
import com.sikaryofficial.backend.domain.dto.req.store.StoreCommentSaveReq;
import com.sikaryofficial.backend.domain.dto.resp.StoreCommentResp;
import com.sikaryofficial.backend.manager.StoreCommentManager;
import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.common.core.utils.PageUtil;
import com.sikaryofficial.common.core.web.domain.PageResult;
import com.sikaryofficial.common.security.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : wuweihong
 * @desc : TODO  请填写你的功能描述
 * @date : 2025-08-21
 */

@RestController
@RequestMapping("/store/font/v1/comment")
@Api(tags = "店铺评论")
public class StoreCommentController {

	@Autowired
	private StoreCommentManager storeCommentManager;

	@PostMapping("publish")
	@ApiOperation(value = "发布店铺评论")
	public R<Void> publish(@Validated @RequestBody StoreCommentSaveReq req) {
		// 发布评论
		storeCommentManager.saveStoreComment(req);
		return R.ok();
	}

	@PostMapping("reply")
	@ApiOperation(value = "回复店铺评论")
	public R<Void> reply(@Validated @RequestBody StoreCommentReplySaveReq req) {
		// 回复评论
		storeCommentManager.saveStoreCommentReply(req);
		return R.ok();
	}

	@PostMapping("page")
	@ApiOperation(value = "分页获取店铺的评论")
	public PageResult<StoreCommentResp> getStoreCommentPage(@Validated @RequestBody StoreCommentListReq req) {
		// 分页获取店铺的评论
		IPage<StoreCommentResp> page = storeCommentManager.getStoreCommentPage(req);
		return PageUtil.success(page.getRecords(), page.getTotal());
	}

}
